Public Class Grupo

    Private mcodigo As Integer 'codigo con el fin de brindar persistencia
    Private mcursos As Curso
    Private mprofesores As List(Of Profesor)
    Private estaCerrado As Boolean
    Private maula As String
    Private mhorario As String
    Private manno As Integer
    Private mnumero As Integer
    Private mcuatrimestre As String
    Private midPlan As Integer 'levantar por demanda el plan
    Private mplanEvaluacion As ComponenteEvaluacion
    Private mlistaEstudiantes As List(Of Estudiante)

    'TODO estos constructores estan oscuros, porque todos en false
    Public Sub New()
        Me.estaCerrado = False
    End Sub
    Public Sub New(ByVal codigo As Integer, ByVal idPlan As Integer)
        Me.estaCerrado = False
        Me.mcodigo = codigo
        Me.midPlan = idPlan
    End Sub
    Public Property Aula() As String
        Get
            Return maula
        End Get
        Set(ByVal Value As String)
            maula = Value
        End Set
    End Property

    Public Property Curso() As Curso
        Get
            If (mcursos Is Nothing) Then
                mcursos = MultiGrupo.LevantarCursoPorGrupo(Me.mcodigo)
            End If
            Return mcursos
        End Get
        Set(ByVal Value As Curso)
            mcursos = Value
        End Set
    End Property

    Public Property Profesores() As List(Of Profesor)
        Get
            If (mprofesores Is Nothing) Then
                mprofesores = MultiProfesor.LevantarProfesoresPorGrupo(Me.mcodigo)
            End If
            Return mprofesores
        End Get
        Set(ByVal Value As List(Of Profesor))
            mprofesores = Value
        End Set
    End Property

    Public Property IsCerrado() As Boolean
        Get
            Return estaCerrado
        End Get
        Set(ByVal Value As Boolean)
            estaCerrado = Value
            MultiGrupo.ModificarEstado(Me.mcodigo, Value)
        End Set
    End Property
    Public Property Horario() As String
        Get
            Return mhorario
        End Get
        Set(ByVal Value As String)
            mhorario = Value
        End Set
    End Property

    Public ReadOnly Property NumeroGrupo() As Integer
        Get
            Return mcodigo
        End Get
        
    End Property

    Public Property Cuatrimestre() As String
        Get
            Return mcuatrimestre
        End Get
        Set(ByVal Value As String)
            mcuatrimestre = Value
        End Set
    End Property

    Public Property Anio() As Integer
        Get
            Return manno
        End Get
        Set(ByVal value As Integer)
            manno = value
        End Set
    End Property

    Public Property PlanEvaluacion() As ComponenteEvaluacion
        Get
            If (mplanEvaluacion Is Nothing) Then
                mplanEvaluacion = MultiPlan.LevantarRubrosObj(Me.midPlan)
            End If
            Return mplanEvaluacion
        End Get
        Set(ByVal Value As ComponenteEvaluacion)
            mplanEvaluacion = Value
            MultiPlan.RegistrarPlanPorGrupo(Me.midPlan, Me.mplanEvaluacion)
        End Set
    End Property

    'Public Sub AgregarCurso(ByVal pcurso As Curso)
    '    mcursos.Add(pcurso)
    'End Sub

    Public Sub AgregarProfesor(ByVal pprofesor As Profesor)
        mprofesores.Add(pprofesor)
    End Sub

    Public Property IdPlan() As Integer
        Get
            Return midPlan
        End Get
        Set(ByVal value As Integer)
            midPlan = value
        End Set
    End Property

    Public Property ListaEstudiantes() As List(Of Estudiante)
        Get
            If (mlistaEstudiantes Is Nothing) Then
                mlistaEstudiantes = MultiEstudiante.LevantarEstudiantesXGrupo(Me.mcodigo)
            End If
            Return mlistaEstudiantes
        End Get
        Set(ByVal Value As List(Of Estudiante))
            mlistaEstudiantes = Value
        End Set
    End Property

    Public Property NumeroCurso() As Integer
        Get
            Return mnumero
        End Get
        Set(ByVal value As Integer)
            mnumero = value
        End Set
    End Property

    'Revisar Me.Cursos.ToString y el de profesores, no se sabe q devuelve eso
    Public Overrides Function ToString() As String
        Dim info As String = ""
        'info = Me.Nombre
        info += "" & Me.Curso.ToString
        info += "" & Me.Profesores.ToString
        Return info
    End Function
End Class
